<template>
  <div class="file-path">
    <a-breadcrumb>
      <a-breadcrumb-item v-for="(item, index) in filePaths" :key="item.id" @click="toDir(item.filePath, index)">
        <span class="path-item">{{ item.fileName }}</span>
      </a-breadcrumb-item>
    </a-breadcrumb>
  </div>
</template>

<script setup lang="ts">
import type { FileItem } from '@/apis'

interface Props {
  filePaths: FileItem[]
}

const emits = defineEmits(['toDir'])

withDefaults(defineProps<Props>(), {
  filePaths: []
})

const toDir = (path: string, index: number) => {
  emits('toDir', path, index)
}
</script>

<style lang="scss" scoped>
.file-path {
  padding: 10px $padding;
  padding-bottom: 12px;
  display: flex;
  align-items: center;
  cursor: pointer;

  .path-item {
    font-size: 12px;

    &:hover {
      color: rgba(var(--primary-6));
    }
  }
}
</style>
